package com.xiaoma.pattern.proxy.jdk.strategy.impl;

import com.xiaoma.pattern.proxy.jdk.strategy.Strategy;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

public class FindLoveStrategy implements Strategy {

  @Override
  public Object invoke(Object proxy, Method method, Object[] args,Object target) {
    if(method.getName().equals("findLove")) {
      System.out.println("策略findlove执行：");
    }else {
      System.out.println("执行原方法");
    }

    Object result = null;
    try {
      result = method.invoke(target,args);
    } catch (IllegalAccessException e) {
      e.printStackTrace();
    } catch (InvocationTargetException e) {
      e.printStackTrace();
    }
    return result;
  }
}
